
<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/xadmin.css">
        <link href="js/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
        <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
        	<!--<script src="js/bootstrap/dist/js/bootstrap.min.js"></script>-->
        	
         <!-- <script type="text/javascript" src="./js/xadmin.js"></script>-->
      <script type="text/javascript" src="js/jquery.min.js" ></script>
      <script type="text/javascript" src="js/jquery.cookie.js"></script>
       </head>
    
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form" id="form1">
                	<input type="hidden" name="commentId"  id="commentId"/>
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red"></span>邮箱</label>
                       <div class="col-sm-10 has-warning">
			<input type="text" autofocus="autofocus" class="form-control" readonly="readonly" id="userId" name="userId"  value="" lay-verify="required" placeholder="请输入" />
		    </div>
		    </div>
                      <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red"></span>类型</label>
                       <div class="col-sm-10 has-warning">
			<input type="text" autofocus="autofocus" class="form-control" readonly="readonly" id="type" name="type" required="" lay-verify="required" placeholder="请输入" />
		    </div>
		    </div>
              
			
			 <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red"></span>点赞数</label>
                       <div class="col-sm-10 has-warning">
			<input type="text" autofocus="autofocus" class="form-control" id="praiseCount" name="praiseCount" required="" lay-verify="required" placeholder="" />
		    </div>
		    </div>
		    
		     <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red"></span>回复数</label>
                       <div class="col-sm-10 has-warning">
			<input type="text" autofocus="autofocus" class="form-control" id="replyCount" name="replyCount" required="" readonly="readonly" lay-verify="required" placeholder="" />
		    </div>
		    </div>
                  
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">评论内容</label>
            <div class="col-sm-10">
				<textarea rows="5" class="form-control" id="content" name="content" lay-verify="required" ></textarea>
			</div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label"></label>
            <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
          <button class="layui-btn-danger layui-btn layui-btn-xs"   href="javascript:;"  id="btn"><i class="layui-icon"></i>退出</button>
  
        </div>
        </form>
        </div>
        </div>
        <script>layui.use(['form', 'layer'],
            function() {
            	$("#id").val($.cookie("id"))
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({
                    nikename: function(value) {
                        if (value.length < 5) {
                            return '昵称至少得5个字符啊';
                        }
                    },
                    pass: [/(.+){6,12}$/, '密码必须6到12位'],
                    repass: function(value) {
                        if ($('#L_pass').val() != $('#L_repass').val()) {
                            return '两次密码不一致';
                        }
                    }
                });
                //获取id
               var commentId=$.cookie("commentId");
                $.ajax({
                            type:"get",
					      	url:"http://localhost:9095/admin/comm/init",
					      	async:true,
					      	data:{
					      		"id":commentId
					      	},
					      	headers: {
								"token2": $.cookie("token2")
							},
					      success(msg){
			if(msg.code==200){
                var userId=msg.data.userId;
                var type=msg.data.type;
                var praiseCount=msg.data.praiseCount;
                var replyCount=msg.data.replyCount;
                var content=msg.data.content;
                $("#type").val(type);
                $("#praiseCount").val(praiseCount);
                $("#replyCount").val(replyCount);
                $("#content").val(content);
                $("#commentId").val(commentId);
                $("#userId").val(userId);
                 $.ajax({
                            type:"get",
					      	url:"http://localhost:9095/admin/comm/selectkey",
					      	async:true,
					      	data:{
					      		"id":userId,
					      	},
					      	headers: {
								"token2": $.cookie("token2")
							},
					      success(msg){
					      	 var email=msg.data.email;
         	                  $("#userId").val(email);
					      }
					      });
                if(type==2){
                	 $("#type").val("课程");
                }else{
                	$("#type").val("文章");
                }
               }else{
               	alert("请求失败")
               }
					      	
					      }
					      });
//       
         	      
         	     


                form.on('submit(add)',
               function(data) {
               	var praiseCount=$("#praiseCount").val();
      	         var content=$("#content").val();
                    $.ajax({
                            type:"post",
					      	url:"http://localhost:9095/admin/comm/update",
					      	async:true,
					      	data:{
					      		"commentId":commentId,
					      		"praiseCount":praiseCount,
					      		"content":content
					      	},
					      	headers: {
								"token2": $.cookie("token2")
							},
                      success(msg){
                    layer.alert("修改成功", {
                        icon: 6
                    },
                    function() {
                        parent.location.reload();
                    });
                    }
                     });
                    return false;
                });

            });</script>
        <script>var _hmt = _hmt || []; (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        
        
        $(function(){
        		
        		//退出
        		$("#btn").click(function(){
        			// 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
        		});
        })
       
        
        	
        	
        	
        
        </script>
    </body>

</html>